import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * A trap subclass that will move fast as this gets to a certain position.
 * 
 * @author Manuel Nava
 * @version 1.0
 */
public class Stalactite extends Trap
{
    private boolean fall;
    
    /**
     * Constructor of the class Stalactite, that sets his boolean variable to false.
     */
    public Stalactite()
    {
        fall=false;
    }
    
     /**
      *Calls the method move from the superclass, if it has get to a certain position it changes his
      * boolean to true, if the boolean is is true calls the method freeFall, and if has get too lower
      * in the world it calls the method disapear.
      */
    public void act() 
    {
        super.move();
        if(getX()<=250)
           fall=true;
        if(fall==true)
        {
            freeFall();
        }
        if(getY()>500)
          disapear();
    }    
    
    /**
     * Moves the object to a lower position in the world.
     */
    public void freeFall()
    {
        setLocation(getX(),getY()+10);
    }
    
     /**
     * Removes the object using the method removeObject from the class World.
     */
    public void disapear()
    {
        getWorld().removeObject(this);
    }   
}
